<!DOCTYPE html>
<html>
<meta charset="utf-8" />
<head>
<title><?php echo $this->config->item('title');?></title>
<link rel="stylesheet" href="<?php echo base_url()?>public/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo base_url()?>public/css/signin.css">
<style type="text/css">
body {
	padding-top: 60px;
	padding-bottom: 40px;
	padding-right: 30px;
}

.sidebar-nav {
	padding: 9px 0;
}

.form-actions button {
	margin-right: 30px;
}

.divX {
	z-index: 100;
	border-style: solid;
	border-width: 2px;
	border-color: #000000;
	-moz-border-radius: 20px;
	-webkit-border-radius: 20px;
	background-color: #ffffff;
	color: red;
	display: block;
}
</style>
<script src="<?php echo base_url()?>public/js/jquery-2.0.2.min.js"></script>
<script src="<?php echo base_url()?>public/js/bootstrap.min.js"></script>
<script src="<?php echo base_url()?>public/js/bootstrap.file-input.js"></script>
<script src="<?php echo base_url()?>public/js/bootstrap-confirm.js"></script>
<script src='<?php echo base_url()?>public/js/jquery.form.js'></script>
<script type="text/javascript">
jQuery(function($) {
	$('.form-signin').ajaxForm({
		dataType:  'json',
		beforeSubmit:  showRequest,
		success:   processJson
	});

	function showRequest(formData, jqForm, options) {
		need_captcha();
		$(".alert").hide(400);
	}

	function processJson(data) {
		if (data.result==false) {
			$(".alert").show(400);
			$("#error_message").text(data.message);
		}else{
			window.location.href=data.message;
		}
	}


        	  	
	$("#user_name").blur(function(){
		if ($(this).val()!="") {
			need_captcha();
		}
	});
	function need_captcha(){
		$.ajax({
		type: "post",
		url: "<?php echo base_url()?>index.php/common_login_manage/need_captcha",
		data:{user_name:$("#user_name").val()},
		dataType:"json",
		beforeSend: function(XMLHttpRequest){
	
		},
		success: function(data, textStatus){
        	if(data.result==true){
				$(".captcha_area").show(200);
			}else{
				$(".captcha_area").hide(200);
				return false;
			}
		},
		complete: function(XMLHttpRequest, textStatus){
		},
		error: function(){
			$(".login_message").find("div").show(200);
			$(".login_message").find("p").text("登录请求失败,请检查你的网络.");
		}
       });

	}
	$("#change_captcha").click(function(){
		$(".captcha").attr("src","<?php echo base_url()."index.php/common_captcha";?>");
	});
});
</script>
</head>
<body>
	<div role="navigation" class="navbar navbar-inverse navbar-fixed-top">
		<div class="container">
			<div class="navbar-header">
				<a class="navbar-brand" href="<?php echo base_url()?>"><?php echo $this->config->item('title');?></a>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="alert alert-danger alert-dismissable" style="display: none;">
			<button type="button" data-dismiss="alert" aria-hidden="true" class="close">&times;</button>
			<div class="text-center" id="error_message"></div>
		</div>
		<form method="post" action="<?php echo base_url()."index.php/common_login_manage/login"?>" role="form" class="form-signin">
			<h2 class="form-signin-heading">员工登录</h2>
			<input id="user_name" type="text" name="user_name" placeholder="账号" required autofocus class="form-control"> 
			<input id="password" type="password" name="password" placeholder="密码" required class="form-control"> 
			<p class="captcha_area" style="display:none;" >
            	<label for="password">验证码</label>
            	<input size="4" type="text" value="" name="captcha" id="captcha" />
            	<img src="<?php echo base_url()."index.php/common_captcha"?>" alt="" class="captcha" />
            	<a href="javascript:void(0)" id="change_captcha">看不清?</a>
	        </p>
			<input id="redirectUrl" type="hidden" name="redirectUrl" value="/">
			<button type="submit" class="btn btn-lg btn-primary btn-block">登录</button>
		</form>
	</div>
</body>
</html>
